cmake_minimum_required(VERSION 3.22)
project(vits)

set(CMAKE_CXX_STANDARD 17)
set(X86_ARCH x86_64)
set(ARM_ARCH aarch64)
if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL ${X86_ARCH})
    set(LIBRARIES_PATH $ENV{HOME}/DataFiles/Libraries)
    set(CANN_PATH ./ascend)
    set(SndFile_DIR ${LIBRARIES_PATH}/libsndfile/lib/cmake/SndFile)
    set(espeak-ng_DIR ${LIBRARIES_PATH}/espeak-ng)
#    set(onnxruntime_DIR ${LIBRARIES}/libonnxruntime)
    set(Torch_DIR ${LIBRARIES_PATH}/libtorch/share/cmake/Torch)
elseif (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL ${ARM_ARCH})
    set(LIBRARIES_PATH $ENV{HOME}/Libraries)
    set(CANN_PATH $ENV{HOME}/Ascend/ascend-toolkit/latest)
    set(SndFile_DIR ${LIBRARIES_PATH}/libsndfile/lib/cmake/SndFile)
    set(espeak-ng_DIR ${LIBRARIES_PATH}/libespeak-ng)
    #    set(onnxruntime_DIR /home/HwHiAiUser/Projects/libonnxruntime)
endif ()
find_package(SndFile REQUIRED)

add_executable(vits main.cpp text_to_phone.cpp)
#        test.cpp)
#add_executable(vits test.cpp)
#find_package(utf8cpp REQUIRED)

target_include_directories(vits PUBLIC ./include ${CANN_PATH}/include ${SndFile_DIR}/include ${espeak-ng_DIR}/include)
find_library(ACL_LIB ascendcl ${CANN_PATH}/lib64)
#find_library(SndFile_LIB sndfile ${SndFile_DIR}/lib)
find_library(espeak-ng_LIB espeak-ng ${espeak-ng_DIR}/lib)
if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL ${X86_ARCH})
    find_package(Torch REQUIRED)
    target_link_libraries(vits SndFile::sndfile ${espeak-ng_LIB} ${TORCH_LIBRARIES})

elseif (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL ${ARM_ARCH})

    target_link_libraries(vits ${ACL_LIB} SndFile::sndfile ${espeak-ng_LIB})
#    utf8::cpp

endif ()
    #target_link_libraries(vits ${ACL_LIB} ${espeak-ng_LIB} utf8::cpp)
